define([
  'text!' + ELMP.resource('components/showColumns/index.html','lib')
],
function (template) {
  return {
    template,
    name: 'ShowColumns',
    props: {
      columns: {
        type: Array,
        default: []
      },
      vxe: {
        type: Element
      }
    },
    computed: {
      showColumns(){
        return this.columns.filter(column=> column.title)
      }
    },
    data () {
      return {
        checkList: []
      }
    },
    created () {
      this.checkList = this.columns.filter(column=> column.title).map(column=>column.title)
    },
    methods: {
      change(data){
        const columns = $._.cloneDeep(this.columns)
        columns.forEach(column=> {
          if(data.includes(column.title)){
            column.visible = true
          }else{
            column.visible = false
          }
        })
        this.vxe?.loadColumn(columns)
      }
    }
  }
})
